"""
@author: Alexander Fruehwirth, Daniel Geymayer
@Version: 1.0
"""

from django import template

register = template.Library()

@register.filter(name='get_range') 
def get_range(value):
    """returns range for given value """
    
    #Special case for five to display star rating correct
    if value == 5:
        return range(1,value+1)
    else:
        return range(value)

@register.filter(name='get_value') 
def get_value(value):
    """Special method for star rating to  display staars in 0.2 steps"""
    value = float(value)
    value =  round(value/5, 1)+0.2
    return "%.1f" % (value)
